package com.api.shopapi.service.impl;

import com.api.shopapi.entity.JKXueya;
import com.api.shopapi.entity.dto.JKXueyaDTO;
import com.api.shopapi.mapper.JKXueyaMapper;
import com.api.shopapi.service.JKXueyaService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("JKXueyaServiceImplOne")
public class JKXueyaServiceImpl implements JKXueyaService {

    @Autowired
    private JKXueyaMapper jkXueyaMapper;

    @Override
    public int insert(JKXueya jkXueya) {
        return jkXueyaMapper.insert(jkXueya);
    }

    @Override
    public int update(JKXueya jkXueya) {
        return jkXueyaMapper.update(jkXueya);
    }

    @Override
    public int delete(String jkXueyaCode) {
        return jkXueyaMapper.delete(jkXueyaCode);
    }

    @Override
    public JKXueya getByJKXueyaCode(String jkXueyaCode) {
        return jkXueyaMapper.getByJKXueyaCode(jkXueyaCode);
    }

    @Override
    public PageInfo<JKXueya> getPageList(int pageIndex, int pageSize, String userCode,String startTime,String endTime) {
        PageHelper.startPage(pageIndex,pageSize);
        List<JKXueya> xueyaList = jkXueyaMapper.getPageList(userCode,startTime,endTime);
        return new PageInfo<>(xueyaList);
    }

    @Override
    public PageInfo<JKXueyaDTO> getAdmPageList(int pageIndex, int pageSize, String name, String governmentCode, String startTime, String endTime) {
        PageHelper.startPage(pageIndex,pageSize);
        List<JKXueyaDTO> jkXueyaDTOList = jkXueyaMapper.getAdmPageList(name, governmentCode, startTime, endTime);
        return new PageInfo<>(jkXueyaDTOList);
    }
}
